package cloudInformation.service.impl;

import cloudEntity.dto.user.SmartUserMoralEducationDetailsUpdateDTO;
import cloudEntity.vo.PageBeanVO;
import cloudEntity.vo.user.SmartUserMoralEducationDetailsVO;
import cloudInformation.mapper.SmartUserMoralEducationDetailsMapper;
import cloudInformation.service.SmartUserMoralEducationDetailsService;
import cn.hutool.core.date.DateTime;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @program: Smart School
 * @ClassName SmartUserMoralEducationDetailsServiceImpl
 * @description:
 * @author: 陈智博
 * @create: 2025-04-14 08:31
 * @Version 1.0
 **/
@Service
public class SmartUserMoralEducationDetailsServiceImpl implements SmartUserMoralEducationDetailsService {

    @Autowired
    private SmartUserMoralEducationDetailsMapper smartUserMoralEducationDetailsMapper;

    @Override
    public Integer updateSmartMoralEducationDetails(SmartUserMoralEducationDetailsUpdateDTO dto) {
        dto.setSysMoralEducationDetailUpdateTime(DateTime.now());
        return smartUserMoralEducationDetailsMapper.updateEducationDetails(dto);
    }

    @Override
    public PageBeanVO<SmartUserMoralEducationDetailsVO> GetEducationDetailsByPageAndLikeName(String personName, Integer pageNum, Integer pageSize) {
        Integer pageBean = (pageNum - 1) * pageSize;
        Integer count = smartUserMoralEducationDetailsMapper.getEducationDetailsCount(personName);
        List<SmartUserMoralEducationDetailsVO> smartUserMoralEducationDetailsVOS = smartUserMoralEducationDetailsMapper.getEducationDetailsByPage(personName,pageBean,pageSize);
        return new PageBeanVO<>(pageNum, pageSize, count, smartUserMoralEducationDetailsVOS);
    }
}
